package cn.wolfcode.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class CourseOrder {
    private Long id;
    //销售时间
    private Date inputTime;
    //客户
    private Customer customer;
    //课程
    private SystemDictionaryItem course;
    //销售金额
    private BigDecimal money;

    public String getJson() {
        HashMap map = new HashMap();
        map.put("id",id);
        map.put("money",money);
        if (customer != null) {
            map.put("customerName",customer.getName());
            map.put("customerId",customer.getId());
        }
        if (course != null) {
            map.put("courseId",course.getId());
        }
        //不能直接传this进去,会出现死循环
        return JSON.toJSONString(map);
    }
}